package com.onpositive.gamemaker.rcp.environment;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.prefs.Preferences;

import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.osgi.service.datalocation.Location;


@SuppressWarnings("restriction")
public class WorkspaceLocationProvider extends WorkspaceLocation
{
	
    // you would probably normally define these somewhere in your Preference Constants
	
	protected static Location instanceLoc;
	 static ChooseWorkspaceData launchData;
	
	static{
		 instanceLoc = Platform.getInstanceLocation();		 
	     if (instanceLoc != null) launchData = new ChooseWorkspaceData(instanceLoc
	                .getDefault());
	     else 
	    	 launchData = new ChooseWorkspaceData(".");
	}
	
	/**
     * Returns whether the user selected "remember workspace" in the preferences
     * 
     * @return
     */
    public static boolean isRememberWorkspace() {
        return !launchData.getShowDialog();
    }
    
    public static void setRememberWorkspace(boolean remember) {
        launchData.setShowDialogValue(remember);
    }
    
    
    
  
    /**
     * Returns the last set workspace directory from the preferences
     * 
     * @return null if none
     */
    public static ChooseWorkspaceData getLaunchData() {
		return launchData;
    }
    
    public static void saveLaunchData() {
    	launchData.writePersistedData();
    }
    
        
}
